﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BillGuru.Persistence;

namespace BillGuru
{
    public partial class FrmCustomer : Form
    {
        public FrmCustomer()
        {
            InitializeComponent();
        }

        private void customerBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.customerBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.billGuruDataSet);

        }

        private void FrmCustomer_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'billGuruDataSet.Customer' table. You can move, or remove it, as needed.
            this.customerTableAdapter.Fill(this.billGuruDataSet.Customer);

            this.customerTableAdapter.Adapter.RowUpdated += new System.Data.OleDb.OleDbRowUpdatedEventHandler(Adapter_RowUpdated);

        }

        void Adapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
        {
            SharedEventHandlerImpl.RetrieveKeyOnRowInsert(sender, e);
        }

        private void FrmCustomer_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this.billGuruDataSet.HasChanges())
                BillGuru.UI.PermissionHandler.checkDataLoss(e);

        }
    }
}
